function delay

global alpha

N=100;
da=0.001;
alpha=1/(2*exp(1));

AA(1)=-1;
BB(1)=0;
alp(1)=1/(2*exp(1));

ep=0.001;
alpha=1/(2*exp(1))+ep;
B=-2*exp(0.5)*ep^0.5;
A=-1+4*exp(1)*ep/3;
for i=1:N
    B=solve(@f,-pi+0.001,0);
    A=-B*cos(B)/sin(B);
    alp(i+1)=alpha;
    AA(i+1)=A;
    BB(i+1)=B;
    if abs(B)>0.8
        alpha=alpha+0.1;
    else
        alpha=alpha+0.001;
    end
end
alpha

figure(1)
% get(gcf)
set(gcf,'Position', [25 1115 658 230])
clf
plot(AA,BB,'b','LineWidth',2)
hold on
plot([-1 -0.01],[0 0],'b','LineWidth',2)
box on
grid on
plot(AA,-BB,'b','LineWidth',2)
plot([-1.1 0.5],[0 0],'k')
plot([0 0],[-2 2],'k')
axis([-1.05 0.41 -1.3*pi/2 1.3*pi/2])
set(gca,'YTick',[-pi/2 0 pi/2])
set(gca,'YTickLabel',{'\pi/2';'0';'\pi/2'})

arrowhead([-0.5 -0.51],[0 0],'b',[1 1.8],2);
ii=80;
arrowhead([AA(ii) AA(ii+1)],[BB(ii) BB(ii+1)],'b',[1 1.8],2);
arrowhead([AA(ii) AA(ii+1)],[-BB(ii) -BB(ii+1)],'b',[1 1.8],2);

xlabel('A','FontSize',16,'FontWeight','bold')
ylabel('B','FontSize',16,'FontWeight','bold')
set(gca,'FontSize',16)

%exportgraphics(gca,'/Users/mark/Desktop/delay.pdf')

function z=f(b)
global alpha
A=-b*cos(b)/sin(b);
z=b-2*alpha*exp(-A)*sin(b);

